package orif.android.welcome;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Welcome extends Activity implements OnClickListener {
	static final int DIALOG_EXAMPLE_ID = 1000;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// Add event listeners
		Button btnExample = (Button) findViewById(R.id.btnExample);
		btnExample.setOnClickListener(this);
	}

	/** Called when a click happens in this Activity */
	public void onClick(View v) {
		if (v == findViewById(R.id.btnExample)) {
			showDialog(DIALOG_EXAMPLE_ID);
		}
	}

	/** Called when a dialog is shown for the first time */
	protected Dialog onCreateDialog(int id) {
		Dialog dialog;
		AlertDialog.Builder builder = new AlertDialog.Builder(this);

		switch (id) {
		case DIALOG_EXAMPLE_ID:
			builder.setMessage(R.string.dlgExample);
			builder.setNeutralButton(R.string.btnOK,
					new DialogInterface.OnClickListener() {
						public void onClick(DialogInterface dialog, int id) {
							dialog.cancel();
						}
					});
			dialog = builder.create();
			break;

		default:
			dialog = null;
		}

		return dialog;
	}
}